package one.stand.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: QIK
 * @CreateDate: 2019/5/14 17:23
 */
@RequestMapping("code")
@RestController
public class CodeController extends BaseController {
    /**
     * 代码提交到相应小程序
     *
     * @param appId
     * @param versionId
     * @return
     */
    @PostMapping("commit")
    public String commit(@RequestParam(value="appId") String appId, @RequestParam(value="versionId") Integer versionId,@RequestParam(value="submitAudit") boolean submitAudit) {
        return JSON.toJSONString(codeService.commit(appId, versionId,submitAudit));
    }

    /**
     * 获取最新审核结果
     *
     * @return
     */
    @PostMapping("getLatestAuditStatus")
    public String getLatestAuditStatus(@RequestParam(value="versionId") Integer versionId,@RequestParam(value="appId") String appId,@RequestParam(value="release") boolean release) {
        return JSON.toJSONString(codeService.getLatestAuditStatus(versionId,appId,release));
    }

    /**
     * 发布小程序
     *
     * @return
     */
    @PostMapping("release")
    public String release(@RequestParam(value="versionId") Integer versionId,@RequestParam(value="appId") String appId) {
        return JSON.toJSONString(codeService.release(versionId,appId));
    }

    /**
     * 提交审核接口
     * @param versionId
     * @return
     */
    @PostMapping("submitAudit")
    public String submitAudit(@RequestParam(value="versionId") Integer versionId,@RequestParam(value="appId") String appId) {
        return JSON.toJSONString(codeService.submitAudit(versionId,appId));
    }

    /**
     * 获取体验码权限
     * @param appId
     * @return
     */
    @PostMapping("getQrCode")
    public String getQrCode(@RequestParam(value="appId") String appId){
        return codeService.getQrCode(appId);
    }
}
